Skip to content

fix(jest): Use relative path for setupFiles in Jest 30#3193

Closed
romtsn wants to merge 1 commit intomasterfrom
rz/fix/jest-setup-files
Closed

fix(jest): Use relative path for setupFiles in Jest 30#3193
romtsn wants to merge 1 commit intomasterfrom
rz/fix/jest-setup-files

Conversation

@romtsn
Copy link
Copy Markdown
Member

@romtsn romtsn commented Mar 9, 2026

Summary

  • Jest 30 no longer resolves <rootDir>/setupTests.js correctly, causing test:jest to fail with Module <rootDir>/setupTests.js in the setupFiles option was not found
  • Switches to ./setupTests.js which works with both Jest 27 and 30
  • Fixes CI failure on release/3.3.1 branch https://github.com/getsentry/sentry-cli/actions/runs/22861477547

Test plan

  • npx jest --listTests resolves correctly
  • Reproduced the failure locally and verified the fix

🤖 Generated with Claude Code

@romtsn romtsn requested review from a team and szokeasaurusrex as code owners March 9, 2026 19:18
@romtsn romtsn added the skip-changelog Apply this label to PRs that do not contain any user-facing changes label Mar 9, 2026
Jest 30 no longer resolves <rootDir>/setupTests.js correctly, causing
CI failures on the release branch. Use ./setupTests.js instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@romtsn romtsn force-pushed the rz/fix/jest-setup-files branch from bc048a3 to 7561187 Compare March 9, 2026 19:23
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

setupFiles: ['<rootDir>/setupTests.js'],
testPathIgnorePatterns: ['<rootDir>/src/', '<rootDir>/tests/integration/'],
setupFiles: ['./setupTests.js'],
testPathIgnorePatterns: ['./src/', './tests/integration/'],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regex wildcard in testPathIgnorePatterns may over-exclude tests

Medium Severity

testPathIgnorePatterns values are treated as regex patterns matched against absolute file paths, not as file system paths. The . in ./src/ and ./tests/integration/ is a regex wildcard (matching any character), not a literal dot meaning "current directory." While <rootDir> was a special Jest token that got replaced with the actual project root path (yielding a precise pattern like /home/user/sentry-cli/src/), ./src/ is a loose regex matching any path containing <any-char>/src/. If the project lives under a path containing /src/ (e.g., /home/dev/src/sentry-cli/), this pattern would match and exclude all test files. The PR description indicates only setupFiles had the <rootDir> resolution issue — testPathIgnorePatterns may not have needed changing.

Fix in Cursor Fix in Web

@romtsn romtsn closed this Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Apply this label to PRs that do not contain any user-facing changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant